package com.beiding.component;

import com.rabbitmq.client.ConfirmCallback;
import org.springframework.amqp.AmqpException;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.core.MessagePostProcessor;
import org.springframework.amqp.core.ReceiveAndReplyCallback;
import org.springframework.amqp.core.ReplyToAddressCallback;
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.ChannelCallback;
import org.springframework.amqp.rabbit.core.RabbitOperations;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.core.ParameterizedTypeReference;



//使用修饰模式,对功能进行拓展

public class MyRabbitTemplateInterlayer implements RabbitOperations {

    RabbitTemplate rabbitTemplate;

    public MyRabbitTemplateInterlayer(RabbitTemplate rabbitTemplate) {
        this.rabbitTemplate = rabbitTemplate;
    }

    @Override
    public <T> T execute(ChannelCallback<T> action) throws AmqpException {
        return rabbitTemplate.execute(action);
    }

    @Override
    public <T> T invoke(OperationsCallback<T> action, ConfirmCallback acks, ConfirmCallback nacks) {
        return rabbitTemplate.invoke(action,acks,nacks);
    }

    @Override
    public boolean waitForConfirms(long timeout) throws AmqpException {
        return rabbitTemplate.waitForConfirms(timeout);
    }

    @Override
    public void waitForConfirmsOrDie(long timeout) throws AmqpException {
        rabbitTemplate.waitForConfirmsOrDie(timeout);
    }

    @Override
    public ConnectionFactory getConnectionFactory() {
        return rabbitTemplate.getConnectionFactory();
    }

    @Override
    public void send(String exchange, String routingKey, Message message, CorrelationData correlationData) throws AmqpException {
        rabbitTemplate.send(exchange, routingKey, message, correlationData);
    }

    @Override
    public void correlationConvertAndSend(Object message, CorrelationData correlationData) throws AmqpException {
        rabbitTemplate.correlationConvertAndSend(message,correlationData);
    }

    @Override
    public void convertAndSend(String routingKey, Object message, CorrelationData correlationData) throws AmqpException {
        rabbitTemplate.convertAndSend(routingKey, message, correlationData);
    }

    @Override
    public void convertAndSend(String exchange, String routingKey, Object message, CorrelationData correlationData) throws AmqpException {
        rabbitTemplate.convertAndSend(exchange, routingKey, message, correlationData);
    }

    @Override
    public void convertAndSend(Object message, MessagePostProcessor messagePostProcessor, CorrelationData correlationData) throws AmqpException {
        rabbitTemplate.convertAndSend(message, messagePostProcessor, correlationData);
    }

    @Override
    public void convertAndSend(String routingKey, Object message, MessagePostProcessor messagePostProcessor, CorrelationData correlationData) throws AmqpException {
        rabbitTemplate.convertAndSend(routingKey, message, messagePostProcessor,correlationData);
    }

    @Override
    public void convertAndSend(String exchange, String routingKey, Object message, MessagePostProcessor messagePostProcessor, CorrelationData correlationData) throws AmqpException {
        rabbitTemplate.convertAndSend(exchange, routingKey, message, messagePostProcessor, correlationData);
    }

    @Override
    public Object convertSendAndReceive(Object message, CorrelationData correlationData) throws AmqpException {
        return rabbitTemplate.convertSendAndReceive(message, correlationData);
    }

    @Override
    public Object convertSendAndReceive(String routingKey, Object message, CorrelationData correlationData) throws AmqpException {
        return rabbitTemplate.convertSendAndReceive(routingKey, message, correlationData);
    }

    @Override
    public Object convertSendAndReceive(String exchange, String routingKey, Object message, CorrelationData correlationData) throws AmqpException {
        return rabbitTemplate.convertSendAndReceive(exchange, routingKey, message, correlationData);
    }

    @Override
    public Object convertSendAndReceive(Object message, MessagePostProcessor messagePostProcessor, CorrelationData correlationData) throws AmqpException {
        return rabbitTemplate.convertSendAndReceive(message, messagePostProcessor, correlationData);
    }

    @Override
    public Object convertSendAndReceive(String routingKey, Object message, MessagePostProcessor messagePostProcessor, CorrelationData correlationData) throws AmqpException {
        return rabbitTemplate.convertSendAndReceive(routingKey, message, messagePostProcessor, correlationData);
    }

    @Override
    public Object convertSendAndReceive(String exchange, String routingKey, Object message, MessagePostProcessor messagePostProcessor, CorrelationData correlationData) throws AmqpException {
        return rabbitTemplate.convertSendAndReceive(exchange, routingKey, message, messagePostProcessor, correlationData);
    }

    @Override
    public <T> T convertSendAndReceiveAsType(Object message, CorrelationData correlationData, ParameterizedTypeReference<T> responseType) throws AmqpException {
        return rabbitTemplate.convertSendAndReceiveAsType(message, correlationData, responseType);
    }

    @Override
    public <T> T convertSendAndReceiveAsType(String routingKey, Object message, CorrelationData correlationData, ParameterizedTypeReference<T> responseType) throws AmqpException {
        return rabbitTemplate.convertSendAndReceiveAsType(routingKey, message, correlationData, responseType);
    }

    @Override
    public <T> T convertSendAndReceiveAsType(Object message, MessagePostProcessor messagePostProcessor, CorrelationData correlationData, ParameterizedTypeReference<T> responseType) throws AmqpException {
        return rabbitTemplate.convertSendAndReceiveAsType(message, messagePostProcessor, correlationData, responseType);
    }

    @Override
    public <T> T convertSendAndReceiveAsType(String routingKey, Object message, MessagePostProcessor messagePostProcessor, CorrelationData correlationData, ParameterizedTypeReference<T> responseType) throws AmqpException {
        return rabbitTemplate.convertSendAndReceiveAsType(routingKey, message, messagePostProcessor, correlationData, responseType);
    }

    @Override
    public <T> T convertSendAndReceiveAsType(String exchange, String routingKey, Object message, MessagePostProcessor messagePostProcessor, CorrelationData correlationData, ParameterizedTypeReference<T> responseType) throws AmqpException {
        return rabbitTemplate.convertSendAndReceiveAsType(exchange, routingKey, message, messagePostProcessor, correlationData, responseType);
    }

    @Override
    public void send(Message message) throws AmqpException {
        rabbitTemplate.send(message);
    }

    @Override
    public void send(String routingKey, Message message) throws AmqpException {
        rabbitTemplate.send(routingKey, message);
    }

    @Override
    public void send(String exchange, String routingKey, Message message) throws AmqpException {
        rabbitTemplate.send(exchange,routingKey,message);
    }

    @Override
    public void convertAndSend(Object message) throws AmqpException {
        rabbitTemplate.convertAndSend(message);
    }

    @Override
    public void convertAndSend(String routingKey, Object message) throws AmqpException {
        rabbitTemplate.convertAndSend(routingKey, message);
    }

    @Override
    public void convertAndSend(String exchange, String routingKey, Object message) throws AmqpException {
        rabbitTemplate.convertAndSend(exchange, routingKey, message);
    }

    @Override
    public void convertAndSend(Object message, MessagePostProcessor messagePostProcessor) throws AmqpException {
        rabbitTemplate.convertAndSend(message, messagePostProcessor);
    }

    @Override
    public void convertAndSend(String routingKey, Object message, MessagePostProcessor messagePostProcessor) throws AmqpException {
        rabbitTemplate.convertAndSend(routingKey, message, messagePostProcessor);
    }

    @Override
    public void convertAndSend(String exchange, String routingKey, Object message, MessagePostProcessor messagePostProcessor) throws AmqpException {
        rabbitTemplate.convertAndSend(exchange, routingKey, message, messagePostProcessor);
    }

    @Override
    public Message receive() throws AmqpException {
        return rabbitTemplate.receive();
    }

    @Override
    public Message receive(String queueName) throws AmqpException {
        return rabbitTemplate.receive(queueName);
    }

    @Override
    public Message receive(long timeoutMillis) throws AmqpException {
        return rabbitTemplate.receive(timeoutMillis);
    }

    @Override
    public Message receive(String queueName, long timeoutMillis) throws AmqpException {
        return rabbitTemplate.receive(queueName, timeoutMillis);
    }

    @Override
    public Object receiveAndConvert() throws AmqpException {
        return rabbitTemplate.receiveAndConvert();
    }

    @Override
    public Object receiveAndConvert(String queueName) throws AmqpException {
        return rabbitTemplate.receiveAndConvert(queueName);
    }

    @Override
    public Object receiveAndConvert(long timeoutMillis) throws AmqpException {
        return rabbitTemplate.receiveAndConvert(timeoutMillis);
    }

    @Override
    public Object receiveAndConvert(String queueName, long timeoutMillis) throws AmqpException {
        return rabbitTemplate.receiveAndConvert(queueName, timeoutMillis);
    }

    @Override
    public <T> T receiveAndConvert(ParameterizedTypeReference<T> type) throws AmqpException {
        return rabbitTemplate.receiveAndConvert(type);
    }

    @Override
    public <T> T receiveAndConvert(String queueName, ParameterizedTypeReference<T> type) throws AmqpException {
        return rabbitTemplate.receiveAndConvert(queueName, type);
    }

    @Override
    public <T> T receiveAndConvert(long timeoutMillis, ParameterizedTypeReference<T> type) throws AmqpException {
        return rabbitTemplate.receiveAndConvert(timeoutMillis, type);
    }

    @Override
    public <T> T receiveAndConvert(String queueName, long timeoutMillis, ParameterizedTypeReference<T> type) throws AmqpException {
        return rabbitTemplate.receiveAndConvert(queueName, timeoutMillis, type);
    }

    @Override
    public <R, S> boolean receiveAndReply(ReceiveAndReplyCallback<R, S> callback) throws AmqpException {
        return rabbitTemplate.receiveAndReply(callback);
    }

    @Override
    public <R, S> boolean receiveAndReply(String queueName, ReceiveAndReplyCallback<R, S> callback) throws AmqpException {
        return rabbitTemplate.receiveAndReply(queueName, callback);
    }

    @Override
    public <R, S> boolean receiveAndReply(ReceiveAndReplyCallback<R, S> callback, String replyExchange, String replyRoutingKey) throws AmqpException {
        return rabbitTemplate.receiveAndReply(callback, replyExchange, replyRoutingKey);
    }

    @Override
    public <R, S> boolean receiveAndReply(String queueName, ReceiveAndReplyCallback<R, S> callback, String replyExchange, String replyRoutingKey) throws AmqpException {
        return rabbitTemplate.receiveAndReply(queueName, callback, replyExchange, replyRoutingKey);
    }

    @Override
    public <R, S> boolean receiveAndReply(ReceiveAndReplyCallback<R, S> callback, ReplyToAddressCallback<S> replyToAddressCallback) throws AmqpException {
        return rabbitTemplate.receiveAndReply(callback, replyToAddressCallback);
    }

    @Override
    public <R, S> boolean receiveAndReply(String queueName, ReceiveAndReplyCallback<R, S> callback, ReplyToAddressCallback<S> replyToAddressCallback) throws AmqpException {
        return rabbitTemplate.receiveAndReply(queueName, callback, replyToAddressCallback);
    }

    @Override
    public Message sendAndReceive(Message message) throws AmqpException {
        return rabbitTemplate.sendAndReceive(message);
    }

    @Override
    public Message sendAndReceive(String routingKey, Message message) throws AmqpException {
        return rabbitTemplate.sendAndReceive(routingKey,message);
    }

    @Override
    public Message sendAndReceive(String exchange, String routingKey, Message message) throws AmqpException {
        return rabbitTemplate.sendAndReceive(exchange, routingKey, message);
    }

    @Override
    public Object convertSendAndReceive(Object message) throws AmqpException {
        return rabbitTemplate.convertSendAndReceive(message);
    }

    @Override
    public Object convertSendAndReceive(String routingKey, Object message) throws AmqpException {
        return rabbitTemplate.convertSendAndReceive(routingKey, message);
    }

    @Override
    public Object convertSendAndReceive(String exchange, String routingKey, Object message) throws AmqpException {
        return rabbitTemplate.convertSendAndReceive(exchange, routingKey, message);
    }

    @Override
    public Object convertSendAndReceive(Object message, MessagePostProcessor messagePostProcessor) throws AmqpException {
        return rabbitTemplate.convertSendAndReceive(message,messagePostProcessor);
    }

    @Override
    public Object convertSendAndReceive(String routingKey, Object message, MessagePostProcessor messagePostProcessor) throws AmqpException {
        return rabbitTemplate.convertSendAndReceive(routingKey, message, messagePostProcessor);
    }

    @Override
    public Object convertSendAndReceive(String exchange, String routingKey, Object message, MessagePostProcessor messagePostProcessor) throws AmqpException {
        return rabbitTemplate.convertSendAndReceive(exchange, routingKey, message, messagePostProcessor);
    }

    @Override
    public <T> T convertSendAndReceiveAsType(Object message, ParameterizedTypeReference<T> responseType) throws AmqpException {

        return rabbitTemplate.convertSendAndReceiveAsType(message, responseType);
    }

    @Override
    public <T> T convertSendAndReceiveAsType(String routingKey, Object message, ParameterizedTypeReference<T> responseType) throws AmqpException {
        return rabbitTemplate.convertSendAndReceiveAsType(routingKey, message, responseType);
    }

    @Override
    public <T> T convertSendAndReceiveAsType(String exchange, String routingKey, Object message, ParameterizedTypeReference<T> responseType) throws AmqpException {
        return rabbitTemplate.convertSendAndReceiveAsType(exchange, routingKey, message, responseType);
    }

    @Override
    public <T> T convertSendAndReceiveAsType(Object message, MessagePostProcessor messagePostProcessor, ParameterizedTypeReference<T> responseType) throws AmqpException {
        return rabbitTemplate.convertSendAndReceiveAsType(message, messagePostProcessor,responseType);
    }

    @Override
    public <T> T convertSendAndReceiveAsType(String routingKey, Object message, MessagePostProcessor messagePostProcessor, ParameterizedTypeReference<T> responseType) throws AmqpException {
        return rabbitTemplate.convertSendAndReceiveAsType(routingKey, message, messagePostProcessor, responseType);
    }

    @Override
    public <T> T convertSendAndReceiveAsType(String exchange, String routingKey, Object message, MessagePostProcessor messagePostProcessor, ParameterizedTypeReference<T> responseType) throws AmqpException {
        return rabbitTemplate.convertSendAndReceiveAsType(exchange, routingKey, message, messagePostProcessor, responseType);
    }

}
